package com.hyj.controller;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hyj.mapper.StudentsMapper;
import com.hyj.entity.Highchartsbingzhuang;
import com.hyj.entity.Userchecks;
import com.hyj.service.BingTuDaoService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2020-06-04
 */

@Controller
public class BingTuController {
	@Autowired
	private BingTuDaoService bingTuDaoService;
	@Autowired
	private StudentsMapper studentmapper;
	@RequestMapping(value="selectAllCount",method=RequestMethod.POST)
	@ResponseBody
	public List<Userchecks> selectAllCount(Userchecks userchecks) {
		// TODO Auto-generated method stub
		Integer selectQDCount = bingTuDaoService.selectQDCount(userchecks);
		Integer selectQTCount = bingTuDaoService.selectQTCount(userchecks);
		Integer selectAllCount = bingTuDaoService.selectAllCount(userchecks);
		List<Userchecks> usercheckss=new ArrayList<Userchecks>();
		usercheckss.add(new Userchecks("总人数",selectAllCount));
		usercheckss.add(new Userchecks("已签出",selectQDCount));
		usercheckss.add(new Userchecks("已签到",selectQTCount));
		
		return usercheckss;
	}
	//学生分配饼图
			@RequestMapping(value="wangluotongjitubing",method=RequestMethod.POST)
			@ResponseBody
			public Highchartsbingzhuang wangluotongjitubing(){
				Integer selectYFPCountStu = studentmapper.selectYFPCountStu();
				Integer selectWFPCountStu = studentmapper.selectWFPCountStu();
				Integer selectALLCountStu = studentmapper.selectALLCountStu();
				Highchartsbingzhuang[] data = new Highchartsbingzhuang[selectALLCountStu];
				DecimalFormat df=new DecimalFormat("0.00");
				Double tongji = 0.0;
				int i = 0;
					Double format =Double.parseDouble(df.format((float)selectYFPCountStu/selectALLCountStu))*100;
					tongji+=(format/100);
					data[i] = new Highchartsbingzhuang("已分配",format, data);
					data[i+1] = new Highchartsbingzhuang("未分配",(1-tongji)*100, data);
				Highchartsbingzhuang highchartsbingzhuang2 = new Highchartsbingzhuang(null, null,data);
				return highchartsbingzhuang2;
			}
}
